package cn.hchaojie.camp.javafx.controls;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class SceneSwitch extends Application {

	@Override
	public void start(Stage stage) throws Exception {
		VBox box1 = new VBox(10);
		box1.setPadding(new Insets(10));
		Button btn1 = new Button("下一页");
		box1.getChildren().addAll(btn1);

		VBox box2 = new VBox(10);
		box2.setPadding(new Insets(10));
		Button btn2 = new Button("上一页");
		box2.getChildren().addAll(btn2);
		
		Scene scene1 = new Scene(box1, 300, 150);
		Scene scene2 = new Scene(box2, 300, 150);
		
		btn1.setOnAction((e) -> {
			stage.setScene(scene2);
		});
		btn2.setOnAction((e) -> {
			stage.setScene(scene1);
		});

		stage.setScene(scene1);

		stage.show();
	}

	public static void main(String[] args) {
		launch(args);
	}
}
